package codechef;

import java.util.Scanner;

public class Course {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);

		int T = in.nextInt();

		Course co = new Course();
		for (int t = 0; t < T; t++) {
			int r = in.nextInt();
			int R = in.nextInt();

			int N = in.nextInt();

			int[] x = new int[N];
			int[] y = new int[N];

			for (int i = 0; i < N; i++) {
				x[i] = in.nextInt();
				y[i] = in.nextInt();
			}

			co.solve(r, R, x, y);

		}

	}

	private void solve(int r, int R, int[] x, int[] y) {
		double res = Double.MAX_VALUE;
		double t = 0.0;
		
		if(x.length == 0) {
			System.out.printf("%.3f\n", (R - r) * 1.0);
			return;
		}


		for (int i = 0; i < x.length; i++) {
			double d = Math.sqrt(x[i] * x[i] + y[i] * y[i]);

			System.out.println(d);
			System.out.println((d-r) + " " + (R-d));
			t = Math.max(d - r, R - d);
			res = Math.min(t, res);
		}
		System.out.printf("%.3f\n", res);
	}

}
